import { createRouter, createWebHistory } from 'vue-router'
import Layout from '../layout/Layout.vue'

const routes = [
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    redirect: '/user', // 重定向页面路由 使得访问/ 就可以进入/home
    children:[
      {
        path: 'user',
        name: 'User',
        component: () => import("@/views/User.vue"),
      },
      {
        path: '/commoditys',
        name: 'Commoditys',
        component: () => import("@/views/Commoditys.vue")
      },
      {
        path: '/coupons',
        name: 'Coupons',
        component: () => import("@/views/Coupons.vue")
      },
      {
        path: '/password',
        name: 'Password',
        component: () => import("@/views/Password.vue")
      },
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import("@/views/Login.vue")
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import("@/views/Register.vue")
  },

]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
